		function [btT,StT]=kalman_smoother(btt,Stt,bnT,SnT,A,MM)
		%[btT StT]=ksmooth(btt,Stt,bnT,SnT,A,cholm)
		% Recursive algorithm 
		% Smoothing recursion.  State evolution equation is
		%    bn=A*bt+e,  Var(e)=omega= cholm'*cholm 
		%    bt|t ~ N(btt,Stt) -- from Kalman Filter
		%    bn|T ~ N(bnT,SnT) -- distribution of bn given full sample. From 
		%                         KF if n=T, otherwise from this recursion
		%    bt|T ~ N(btT,StT)
		% ===================================
		% NOTE for RESTRECITED STATES: 
        % btt is ssx1 bnT is jjx1 , btT is ssx1
        % Stt is ss x ss , SnT is zeros jjxjj 
        % A  is jjxss, omega is jjxjj
		% btt and bnT must be fed as  COLUMN VECTORS
        
        % ======================================
		% Note: SMOOTHER FOR GIBBS SAMPLING  
		% For restricted state vectors where only first JJ rows 
		AS=A*Stt; % G*xP(t)|t  
		% JJ*ss
		G=AS*A'+ MM*MM'; %  P*(t+1)|t  
		% With a restricted state G is JJ*JJ 
		SAGI=AS'/G; % Solve X*P(t+1)|t=P(t)|t*G'  
		% Resticted is ss X JJ
		btT=SAGI*(bnT-A*btt)+btt;  % s(t)|T=P(t)|t*G'*inv(P(t+1))*(s(t+1)|T-s(t+1)|t)) +  S(t)|T
		StT=Stt-SAGI*AS+SAGI*SnT*SAGI'; % See appended page 
 